<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>职位管理</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script type="text/javascript">
function tipOpen(ele) {
	$(".tipright p").text("您确定要修改此职位吗?");
	$("#tip").fadeIn(200);
    var jid = $(ele).prev().val();
    $("#jid2").val(jid);
}
function tipClose() {
	$("#tip").fadeOut(200);
}
function yes() {
  $("#tip").fadeOut(200);
  var jid = $("#jid2").val();
  window.location.href="/sys/job/updateStatus?id="+jid;
}
function warning(ele) {
  $(".tipright p").text("请先启用该职位所在部门！");
  $("#tip2").fadeIn(200);
}
function tipClose2() {
  $("#tip2").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>系统管理</li>
    <li>职位管理</li>
  </ul>
</div>
<div class="rightinfo">
  <form id="jobForm" th:action="@{/sys/job/findByPage}" method="post">
    <input type="hidden" name="pageno" id="pageno" />
    <ul class="tools">
      <li> <label>职位名称:</label>
        <input id="jobName" name="jobName" th:value="${job==null?'':job.jobName}" type="text" />
      </li>
      <li> <label>所属部门：</label>
        <select name="jobDeptId">
          <option value="0">请选择部门</option>
          <option th:each="d:${dlist}" th:value="${d.deptId}" th:text="${d.deptName}"
                  th:selected="${d.deptId==job.jobDeptId?'true':'false'}">研发</option>
        </select>
      </li>
      <li class="subBut" onclick="Search(1)"><img th:src="@{/images/t06.png}" />查询</li>
      <li class="subBut" onclick="window.location.href='/erp/sys/dept/positionAdd.html'"><img th:src="@{/images/t01.png}" />添加</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>职位</th>
          <th>所属部门</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr th:each="j,var : ${pageInfo.records}">
          <td th:text="${(pageInfo.current-1)*pageInfo.size+var.count}"></td>
          <td th:text="${j.jobName}">经理</td>
          <td th:text="${j.jobDeptId==null?'':j.dept.deptName}">研发部</td>
          <td th:text="${j.jobState=='1'?'启用':'禁用'}">正常</td>
          <td>
            <a th:if="${session.users.jobId==1||(session.users.jobId==9&&j.jobId!=1)}" th:href="@{'/sys/job/goUpdate?id='+${j.jobId}}" class="tablelink">修改</a>
            <input type="hidden" th:value="${j.jobId}" />
            <a th:if="${session.users.jobId==1||(session.users.jobId==9&&j.jobId!=1)}" th:href="@{'/sys/job/grantPage/'+${j.jobId}}" class="tablelink">赋权</a>
            <input type="hidden" th:value="${j.jobId}" />
            <a href="javascript:void(0);" th:if="${j.dept.deptState=='1'&&(session.users.jobId==1||(session.users.jobId==9&&j.jobId!=1))}" th:text="${j.jobState.equals('1')?'注销':'恢复'}" class="tablelink" onclick="tipOpen(this)">注销</a>
            <input type="hidden" th:value="${j.jobId}" />
            <a href="javascript:void(0);" th:if="${j.dept.deptState=='2'&&(session.users.jobId==1||(session.users.jobId==9&&j.jobId!=1))}" th:text="${j.jobState.equals('1')?'注销':'恢复'}" class="tablelink" onclick="warning(this)">注销</a>
          </td>
        </tr>
      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue" th:text="${pageInfo.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${pageInfo.current}">2&nbsp;</i>页</div>
      <ul class="paginList">
        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="Search([[${pageInfo.hasPrevious()?pageInfo.current-1:1}]])">
            <span th:class="${pageInfo.hasPrevious()?'pagenxt roate':'pagepre'}"></span>
          </a>
        </li>
        <li class="paginItem" th:if="${1+4<=pageInfo.current}">
          <a th:onclick="Search(1)" href="javascript:void(0);">1</a>
        </li>
        <li class="paginItem more" th:if="${1+5<=pageInfo.current}">
          <a href="javascript:void(0);">...</a>
        </li>
        <li class="paginItem" th:if="${1+3<=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current-3}]])" href="javascript:void(0);" th:text="${pageInfo.current-3}">3</a>
        </li>
        <li class="paginItem" th:if="${1+2<=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current-2}]])" href="javascript:void(0);" th:text="${pageInfo.current-2}">4</a>
        </li>
        <li class="paginItem" th:if="${1+1<=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current-1}]])" href="javascript:void(0);" th:text="${pageInfo.current-1}">1</a>
        </li>
        <li class="paginItem current">
          <a href="javascript:void(0);" th:text="${pageInfo.current}">2</a>
        </li>
        <li class="paginItem" th:if="${pageInfo.pages-1>=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current+1}]])" href="javascript:void(0);" th:text="${pageInfo.current+1}">3</a>
        </li>
        <li class="paginItem" th:if="${pageInfo.pages-2>=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current+2}]])" href="javascript:void(0);" th:text="${pageInfo.current+2}">4</a>
        </li>
        <li class="paginItem" th:if="${pageInfo.pages-3>=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.current+3}]])" href="javascript:void(0);" th:text="${pageInfo.current+3}">5</a>
        </li>
        <li class="paginItem more" th:if="${pageInfo.pages-5>=pageInfo.current}">
          <a href="javascript:void(0);">...</a>
        </li>
        <li class="paginItem" th:if="${pageInfo.pages-4>=pageInfo.current}">
          <a th:onclick="Search([[${pageInfo.pages}]])" href="javascript:void(0);" th:text="${pageInfo.pages}">10</a>
        </li>
        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="Search([[${pageInfo.hasNext()?pageInfo.current+1:pageInfo.pages}]])">
            <span th:class="${pageInfo.hasNext()?'pagenxt':'pagepre roate'}"></span>
          </a>
        </li>
      </ul>
    </div>
  </form>

  <script>
    function Search(current) {
      $("#pageno").val(current);
      $("#jobForm").submit();
    }
  </script>
  <!-- 提示框 -->
  <div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img th:src="@{/images/ticon.png}" /></span>
      <div class="tipright">
        <p></p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <input type="hidden" id="jid2"   />
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" onclick="yes()" />
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose()" />
    </div>
  </div>

  <!-- 提示框2 -->
  <div id="tip2" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose2()"></a></div>
    <div class="tipinfo"> <span><img th:src="@{/images/ticon.png}" /></span>
      <div class="tipright">
        <p></p>
        <cite></cite> </div>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" onclick="tipClose2()" />
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose2()" />
    </div>
  </div>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
